package com.iuie.ns.system.shiro.filter;

import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;

import com.iuie.ns.system.myemun.LoginTypeEnum;
import com.iuie.ns.system.shiro.token.CaptchaUsernamePasswordToken;

public class MyHashedCredentialsMatcher extends HashedCredentialsMatcher{

	@Override
	public boolean doCredentialsMatch(AuthenticationToken token,
			AuthenticationInfo info) {
		
		CaptchaUsernamePasswordToken cap = (CaptchaUsernamePasswordToken)token;
		
		if(StringUtils.isNotBlank(cap.getLoginType()) 
				&& LoginTypeEnum.BY_TOKEN.getCode().equals(cap.getLoginType())){
			return true;
		}
		
		return super.doCredentialsMatch(token, info);
	}
}
